package com.xianniu.ltc.controller.general;

import cn.devezhao.commons.web.ServletUtils;
import cn.devezhao.persist4j.Entity;
import cn.devezhao.persist4j.Field;
import cn.devezhao.persist4j.engine.ID;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.rebuild.api.RespBody;
import com.rebuild.core.configuration.ConfigBean;
import com.rebuild.core.configuration.general.AutoFillinManager;
import com.rebuild.core.configuration.general.TransformManager;
import com.rebuild.core.metadata.MetadataHelper;
import com.rebuild.core.service.general.transform.RecordTransfomer;
import com.rebuild.web.BaseController;
import com.rebuild.web.EntityParam;
import com.rebuild.web.IdParam;
import com.rebuild.web.user.signup.LoginController;
import com.xianniu.ltc.service.EquipmentApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 表单功能扩展
 *
 * @author wangrj wangruijie@xianniu.cn
 * @since 2019/05/20
 */
@RestController
@RequestMapping("/xn/app/entity/extras/")
public class XnFormExtrasController extends BaseController {

    @Autowired
    private EquipmentApiService equipmentApiService;
    // 获取表单回填数据
    @RequestMapping("fillin-value")
    public JSON getFillinValue(HttpServletRequest request) {
        String entity = getParameter(request, "entity");
        String source = getParameter(request, "source");
        String tenantCode = (String) ServletUtils.getSessionAttribute(request, LoginController.TENANT_CODE);
        // 通过ID调用资源管理查询设备信息
//        if (entity.equalsIgnoreCase("shebeibomguanxi")){
//            return equipmentApiService.selectEquipmentById(source, tenantCode);
//        }
        return null;
    }
}
